<?php

require_once('./functions.inc.php');
require_once('./database.inc.php');
require_once('./track.inc.php');

hit();

$lastupdate = GetLastUpdate();

$dbm = connect_db("dbm");

$query = mysql_query("SELECT * FROM `teams_$lastupdate` WHERE userid > 0 AND hassupporter = 1 ORDER BY RAND() LIMIT 1", $dbm) or die (mysql_error());

$row = mysql_fetch_array($query);
?>
<html>
<head>
<title>A random team to support, for the Random Support Federation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
echo "the last update of the database was on $lastupdate, so the data may not be accurate, and no users that received their team after this date are included in the draw. Should the suggested team be unacceptable, just hit reload to get a new suggestion.<br /><br />\n";
echo "A random team with supporter: {$row['TeamName']} ({$row['TeamID']} - <a href=\"http://www.hattrick.org/common/teamdetails.asp?teamid={$row['TeamID']}\">link</a>)<br />\n";
?>
</body>
</html>
